import * as request from "@/utils/request"

const API_PREFIX = "/Menu"

/**
 * 创建菜单
 */
export function menuCreate(params: MenuCreateRequest) {
  return request.post<boolean>({
    url: API_PREFIX + "/Create",
    data: params
  })
}

/**
 * 删除菜单
 *
 * @param id 菜单 id
 */
export function menuDelete(params: DeleteRequest) {
  return request.get<boolean>({
    url: API_PREFIX + "/Delete",
    params
  })
}

/**
 * 编辑菜单
 */
export function menuEdit(params: MenuEditRequest) {
  return request.post<boolean>({
    url: API_PREFIX + "/Edit",
    data: params
  })
}

/**
 * 获取菜单详情
 *
 * @param id 菜单id
 */
export function getMenuById(params: GetMenuByIdRequest) {
  return request.get<MenuResponse>({
    url: API_PREFIX + "/Get",
    params
  })
}

/**
 * 获取所有菜单
 *
 * @param menuName 菜单名称
 */
export function getAllMenu(params: MenuQueryRequest) {
  return request.get<MenuTreeResponse[]>({
    url: API_PREFIX + "/GetAll",
    params
  })
}

/**
 * 分页获取菜单
 */
export function getMenuByPage(params: PageRequest) {
  return request.get<PageResponse<MenuResponse>>({
    url: API_PREFIX + "/GetPage",
    params
  })
}

/**
 * 获取树状结构菜单
 */
export function getTreeMenu() {
  return request.get<MenuTreeResponse[]>({
    url: API_PREFIX + "/GetTree"
  })
}
